package com.woniuxy.goods.controller;


import com.woniuxy.core.util.Result;
import com.woniuxy.goods.entity.ProcessExecute;
import com.woniuxy.goods.entity.ProcessModel;
import com.woniuxy.goods.service.ProcessModelService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *  流程模型控制层接口
 * @author ...
 * @since 2024年05月22日
 */
@RestController
@Api(tags = "典当流程模版管理接口")
@RequestMapping("/processModel")
public class ProcessModelController {
    /**
     * 流程模型服务层接口
     */
    @Resource
    private ProcessModelService processModelService;

    /**
     * 根据流程id查出对应流程模型
     * @param processId 流程id
     * @return 流程模型
     * @throws Exception
     */
    @ApiOperation("根据流程id查出对应流程模型接口")
    @ApiImplicitParam("流程id")
    @ApiResponses({
            @ApiResponse(code = 200,message = "OK",response = ProcessModel.class)
    })
    @GetMapping("/findModelByProcessId")
    public Result findModelByProcessId(Integer processId) throws Exception{
        List<ProcessModel> models = processModelService.findModelByProcessId(processId);
        return Result.success("根据流程id查出对应流程模型成功",models);
    }

    /**
     * 根据流程码查出对应流程状态名称
     * @param stateNUm 流程码
     * @param processId 流程id
     * @return 流程状态名称
     * @throws Exception
     */
    @ApiOperation("根据流程码查出对应流程状态名称")
    @ApiImplicitParam("流程码")
    @GetMapping("/findStateNameByNum")
    public Result findStateNameByNum(Integer stateNUm,Integer processId) throws Exception{
        String stateName = processModelService.findStateNameByNum(stateNUm,processId);
        return Result.success("根据流程码查出对应流程状态名称成功",stateName);
    }

}

